package client.comm.baoding.adapter

import android.content.Context
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import client.comm.baoding.R
import client.comm.baoding.api.bean.GoodsOrder
import client.comm.baoding.databinding.LayoutOrderjlitem2Binding
import client.comm.commlib.base.BaseLoadmoreAdapter
import client.comm.commlib.base.BindingViewHoder
import com.bumptech.glide.RequestManager

class OrderjlAdapter : BaseLoadmoreAdapter<GoodsOrder.Order> {

    val manager: RequestManager

    constructor(context: Context, manager: RequestManager) : super(context) {
        this.manager = manager
    }

    override fun createVh(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return BindingViewHoder(
            DataBindingUtil.inflate(
                layoutInflater,
                R.layout.layout_orderjlitem2,
                parent,
                false
            )
        )
    }

    override fun bindVh(holder: RecyclerView.ViewHolder, position: Int) {
        val bindingViewHolder = holder as BindingViewHoder<ViewDataBinding>
        val binding = bindingViewHolder.binding as LayoutOrderjlitem2Binding
        val bean = getItem(position)
        binding.bean = bean
//        binding.isShowTuiKuan = false
//        binding.itemWrap.removeAllViews()
//        for (i in bean.goods_list) {
//            DataBindingUtil.inflate<LayoutGoodswrapitemBinding>(
//                LayoutInflater.from(context), R.layout.layout_goodswrapitem, binding.itemWrap, false
//            ).apply {
//                manager.load(i.goods_img).error(R.mipmap.ic_launcher).into(img)
//                this.bean = i
//                binding.itemWrap.addView(root)
//            }
//        }
    }

}